package io.modifier.basic.emo.device

class CacheRunner<T, R>(private val action: (T) -> R?) {

    @Volatile
    private var value: R? = null

    fun get(param: T): R? {
        return value ?: synchronized(this) {
            value ?: action(param)?.also { value = it }
        }
    }
}
